importClass(Packages.org.framework2.utils.XMLReader);
importClass(Packages.org.framework2.utils.HttpClientUtil);
importClass(Packages.org.framework2.utils.DBTools);

var xmlData = request.getParameter('xmldata');
//print('请求的参数:' + xmlData);
var xmlReader = new XMLReader(xmlData);

var ret = '<?xml version="1.0" encoding="UTF-8"?>';
ret += '<InnerBus>';
ret += '<Response>';
ret += '<RspCode>000000</RspCode>';
ret += '<RspDesc>[TMPT]成功</RspDesc>';
ret += '</Response>';
ret += '</InnerBus>';
response.write(ret);
/*
模拟下载平台回执


var logs = dbTools.select('select \'中文\' from dual');
println(logs);

var map = new java.util.HashMap();
map.put('xmlData',ret);
HttpClientUtil.post('http://localhost:8888/testCase/testcase2.do', 5000, map);
*/
var resourceIDs = new Array('000002','000008');
var transID = xmlReader.getNodeText('InnerBus.SvcCont.ProductDeployNotifyReq.TransactionID');
var procID = xmlReader.getNodeText('InnerBus.ProcID');
var resURL = '/CMS4-DIST/ibus/confirmDownLoadForMusicController.do';
//
var retStr = '<?xml version="1.0" encoding="utf-8"?>';
retStr += '<Cms>';
retStr += '<SvcCont>';
retStr += '<DownDeployReportReq>';
retStr += '<EnableID>1000001</EnableID>';
retStr += '<Action>0</Action>';
retStr += '<TransactionID>'+transID+'</TransactionID>';

var lastChar = transID.substring(transID.length - 1);
if(lastChar == 9)
{
	retStr += '<Result>1</Result>';
}
else
{
	retStr += '<Result>0</Result>';
}

retStr += '<UrlItem>';
for(var i = 0; i < resourceIDs.length; i++){
	retStr += '<RspURLItem>';
	retStr += '<ResourceID>' + resourceIDs[i] + '</ResourceID>';
	retStr += '<Result>0</Result>';
	retStr += '<Url></Url>';
	retStr += '<PreviewURL></PreviewURL>';
	retStr += '</RspURLItem>';
}
retStr += '<CmpID>011</CmpID>';
retStr += '<ContentID>000000000000000000000000000000000000</ContentID>';
retStr += '</UrlItem>';
retStr += '</DownDeployReportReq>';
retStr += '</SvcCont>';
retStr += '<ProcID>a' + procID + '</ProcID>';
retStr += '</Cms>';
var map = new java.util.HashMap();
map.put('xmldata',retStr);
println(retStr);
HttpClientUtil.post('http://10.25.102.143:5657/CMS4-DIST/ibus/confirmDownLoadForMusicController.do', 5000, map);